for arg in cmd {
p = p.arg(arg);
}
+ match cx.resolve.features(pkg.get_package_id()) {
+ Some(features) => {
+ for feat in features.iter() {
+ let feat = feat.as_slice().chars()
+ .map(|c| c.to_uppercase())
+ .map(|c| if c == '-' {'_'} else {c})
+ .collect::<String>();
+ p = p.env(format!("CARGO_FEATURE_{}", feat).as_slice(), Some("1"));
+ }
+ }
+ None => {}
+ }
+
+
for &(pkg, _) in cx.dep_targets(pkg).iter() {
let name: String = pkg.get_name().chars().map(|c| {
match c {
profile currently being built.
* `PROFILE` - name of the profile currently being built (see
[profiles][profile]).
+* `CARGO_FEATURE_<name>` - For each activated feature of the package being
+ built, this environment variable will be present
+ where `<name>` is the name of the feature uppercased
+ and having `-` translated to `_`.
[profile]: manifest.html#the-[profile.*]-sections
version = "0.5.0"
authors = ["wycats@example.com"]
+ [features]
+ foo = []
+
[[bin]]
name = "foo"
"#)
use std::io::fs::PathExtensions;
fn main() {{
let _ncpus = os::getenv("NUM_JOBS").unwrap();
+ let _feat = os::getenv("CARGO_FEATURE_FOO").unwrap();
let debug = os::getenv("DEBUG").unwrap();
assert_eq!(debug.as_slice(), "true");
}}
"#,
p.root().join("target").join("native").display()));
- assert_that(build.cargo_process("build"), execs().with_status(0));
+ assert_that(build.cargo_process("build").arg("--features").arg("foo"),
+ execs().with_status(0));
p = p
authors = ["wycats@example.com"]
build = '{}'
+ [features]
+ foo = []
+
[[bin]]
name = "foo"
.file("src/foo.rs", r#"
fn main() {}
"#);
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo_process("build").arg("--features").arg("foo"),
+ execs().with_status(0));
})
test!(crate_version_env_vars {